package TestDemo.example.service.impl;

import TestDemo.example.mapper.DeptMapper;
import TestDemo.example.pojo.Dept;
import TestDemo.example.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


import java.time.LocalDateTime;
import java.util.ArrayList;

@Service
public class DeptServiceImpl implements DeptService {
    @Autowired
    private DeptMapper deptMapper;
    @Override
    public ArrayList<Dept> deptArrayList() {
        return deptMapper.deptArrayList();
    }

    @Override
    public void deleteById(Integer id) {
        deptMapper.deleteById(id);
    }

    @Override
    public void add(Dept dept) {
        dept.setCreateTime(LocalDateTime.now());
        dept.setUpdateTime(LocalDateTime.now());
        deptMapper.add(dept);
    }

    @Override
    public Dept findDeptById(Integer id) {
        return deptMapper.findDeptById(id);
    }

    @Override
    public void updateById(Dept dept) {
        dept.setUpdateTime(LocalDateTime.now());
        System.out.println(dept.getId());
        deptMapper.updateById(dept);
    }
}
